/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is Forte for Java, Community Edition. The Initial
* Developer of the Original Code is Sun Microsystems, Inc. Portions
* Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.autoupdate;
import javax.swing.JButton;
import java.util.ResourceBundle;
import org.openide.DialogDescriptor;
import org.openide.NotifyDescriptor;
import org.openide.TopManager;
import org.openide.util.NbBundle;
import org.openide.util.HelpCtx;
/** Panel and dialog for showing LicenceAgreement.
* @author Petr Hrebejk
*/
public class LicenceDialog extends javax.swing.JPanel {
/** The resource bundle */
private static final ResourceBundle bundle = NbBundle.getBundle( LicenceDialog.class );
/** Preferred size of this dialog */
private static final java.awt.Dimension preferredSize = new java.awt.Dimension( 620, 475 );
/** The only Licence panel instance in system */
private static LicenceDialog licencePanel;
/** The dialog descriptor of licence dialog */
private static DialogDescriptor dialogDescriptor = null;
/** The Licence dialog */
private static java.awt.Dialog dialog = null;
/** Licence dialog Accept button */
private static JButton acceptButton;
/** Licence dialog Decline button */
private static JButton declineButton;
/** Is the licence accepted */
private static boolean accepted = false;
static final long serialVersionUID =-4862117522808181670L;
/** Creates new form LicencePanel */
public LicenceDialog() {
initComponents ();
}
/** Overload getPreffered size to get a bit bigger dialog */
public java.awt.Dimension getPreferredSize() {
return preferredSize;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents () {//GEN-BEGIN:initComponents
jScrollPane1 = new javax.swing.JScrollPane ();
licenceTextArea = new javax.swing.JTextArea ();
setLayout (new java.awt.BorderLayout ());
setBorder (new javax.swing.border.EmptyBorder(new java.awt.Insets(8, 8, 8, 8)));
licenceTextArea.setEditable (false);
licenceTextArea.setFont (new java.awt.Font ("Monospaced", 0, 12)); // NOI18N
jScrollPane1.setViewportView (licenceTextArea);
add (jScrollPane1, java.awt.BorderLayout.CENTER);
}//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea licenceTextArea;
// End of variables declaration//GEN-END:variables
void setLicenceText( String licenceText ) {
licenceTextArea.setText( licenceText );
licenceTextArea.setCaretPosition(0);
licenceTextArea.revalidate();
}
static boolean acceptLicence( String licenceText ) {
if ( dialog == null ) {
createDialog();
}
licencePanel.setLicenceText( licenceText );
accepted = false;
dialog.show();
return accepted;
}
private static void createDialog() {
licencePanel = new LicenceDialog();
acceptButton = new JButton( bundle.getString( "CTL_Licence_Accept" ) );
declineButton = new JButton( bundle.getString( "CTL_Licence_Decline" ) );
dialogDescriptor = new DialogDescriptor(
licencePanel,
bundle.getString( "CTL_Licence_Title" ),
true, // Modal
new Object[] { acceptButton, declineButton }, // Option list
acceptButton, // Default
DialogDescriptor.BOTTOM_ALIGN, // Align
new HelpCtx ( LicenceDialog.class ), // Help
new java.awt.event.ActionListener() {
public void actionPerformed( java.awt.event.ActionEvent evt ) {
if ( evt.getSource() == acceptButton )
accepted = true;
else
accepted = false;
dialog.setVisible( false );
}
});
dialog = TopManager.getDefault().createDialog( dialogDescriptor );
}
}
/*
* Log
* 6 Gandalf 1.5 1/12/00 Petr Hrebejk i18n
* 5 Gandalf 1.4 12/22/99 Petr Hrebejk Various bugfixes
* 4 Gandalf 1.3 11/27/99 Patrik Knakal
* 3 Gandalf 1.2 10/22/99 Ian Formanek NO SEMANTIC CHANGE - Sun
* Microsystems Copyright in File Comment
* 2 Gandalf 1.1 10/11/99 Petr Hrebejk Last minute fixes
* 1 Gandalf 1.0 10/7/99 Petr Hrebejk
* $
*/